﻿<r:RibbonWindow x:Class="CMinus.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:me="clr-namespace:CMinus"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
    Background="{DynamicResource WindowBackground}"
    WindowStartupLocation="CenterScreen"
    Title="C- Compiler" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="600" Width="800">
    
    <r:RibbonWindow.Resources>
        <ResourceDictionary>
        <!-- Uncomment below for Office 2007 Blue -->
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Blue.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <!-- Uncomment below for Office 2007 Silver -->
        <!--<ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Silver.xaml" />
            </ResourceDictionary.MergedDictionaries>-->
        <!-- Uncomment below for Office 2007 Black -->
        <!--<ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/RibbonControlsLibrary;component/Themes/Office2007Black.xaml" />
            </ResourceDictionary.MergedDictionaries>-->         
        <LinearGradientBrush x:Key="dgHeaderBrush" StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Color="#FF6B8E95" Offset="0"/>
            <GradientStop Color="#FF14A7C1" Offset="1"/>
            <GradientStop Color="#FF1E424E" Offset="0.509"/>
            <GradientStop Color="#FF1D4855" Offset="0.542"/>
            <GradientStop Color="#FF1D4855" Offset="0.542"/>
            <GradientStop Color="#FF193A44" Offset="0.526"/>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="dgHeaderBorderBrush" StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Color="#FF1D1D1D" Offset="0.614"/>
            <GradientStop Color="#FF007F96" Offset="0.853"/>
            <GradientStop Color="#FF0AEAFA" Offset="1"/>
        </LinearGradientBrush>

        <Style x:Key="dgHeaderStyle" TargetType="GridViewColumnHeader">
            <Setter Property="Background" Value="{StaticResource dgHeaderBrush}" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="BorderBrush" Value="{StaticResource dgHeaderBorderBrush}" />
        </Style>

        <Style x:Key="dgRowStyle" TargetType="ListViewItem">
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Background" Value="White" />
            <Style.Triggers>
                <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                    <Setter Property="Background" Value="#FFD0D0E0" />
                </Trigger>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="LightGoldenrodYellow" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <ImageBrush x:Key="WindowBackground" Stretch="Fill" 
                    ImageSource="Images/Wave.jpg" />
    </ResourceDictionary>
    </r:RibbonWindow.Resources>
    <!-- Command bindings -->
    <r:RibbonWindow.CommandBindings>
        <CommandBinding Command="me:AppCommands.AddNew" Executed="OnNewFile" />
        <CommandBinding Command="me:AppCommands.Open" Executed="OnOpenFile"/>
        <CommandBinding Command="me:AppCommands.Save" Executed="OnSaveFile"/>
        <CommandBinding Command="me:AppCommands.Help" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.LexicalAnalysis" Executed="LexicalAnalysis" />
		<CommandBinding Command="me:AppCommands.SyntaxAnalysis" Executed="SyntaxAnalysis" />
        <CommandBinding Command="me:AppCommands.SemanticAnalysis" Executed="SemanticAnalysis" />
        <CommandBinding Command="me:AppCommands.TargetCodeGeneration" Executed="TargetCodeGeneration" />

        <CommandBinding Command="me:AppCommands.Cut" CanExecute="CanCut" Executed="OnCut" />
        <CommandBinding Command="me:AppCommands.Copy" CanExecute="CanCopy" Executed="OnCopy" />
        <CommandBinding Command="me:AppCommands.Paste" CanExecute="CanPaste" Executed="OnPaste" />
        <!--<CommandBinding Command="me:AppCommands.Reconcile" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.CashflowReport" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.Transfer" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.DownloadStatements" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.DownloadCreditCards" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.Backup" Executed="OnIgnore" />
        <CommandBinding Command="me:AppCommands.Calculator" Executed="OnIgnore" />-->
    </r:RibbonWindow.CommandBindings>

    <Viewbox Stretch="Fill">
    <Canvas Height="600" Width="800" >
    <DockPanel Canvas.Left="0" Canvas.Top="0">
            <r:Ribbon DockPanel.Dock="Top" Height="138" Width="799.285"  FocusManager.IsFocusScope="True" Title="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}},Path=Title}">
                <r:Ribbon.Resources>
                    <r:RibbonGroupSizeDefinitionCollection x:Key="RibbonLayout">
                        <r:RibbonGroupSizeDefinition>
                            <!-- Control sizes: L,L,L -->
                            <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                            <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                            <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                        </r:RibbonGroupSizeDefinition>
                        <r:RibbonGroupSizeDefinition>
                            <!-- Control sizes: L,M,M -->
                            <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                            <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                            <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="True"/>
                        </r:RibbonGroupSizeDefinition>
                        <r:RibbonGroupSizeDefinition>
                            <!-- Control sizes: L,S,S -->
                            <r:RibbonControlSizeDefinition ImageSize="Large" IsLabelVisible="True"/>
                            <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="False"/>
                            <r:RibbonControlSizeDefinition ImageSize="Small" IsLabelVisible="False"/>
                        </r:RibbonGroupSizeDefinition>
                        <!-- Collapsed -->
                        <r:RibbonGroupSizeDefinition IsCollapsed="True" />
                    </r:RibbonGroupSizeDefinitionCollection>
                </r:Ribbon.Resources>
                <r:Ribbon.QuickAccessToolBar>
                    <r:RibbonQuickAccessToolBar CanUserCustomize="True">
                            <r:RibbonButton Command="me:AppCommands.Open" 
                 r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar" />
                            <r:RibbonButton Command="me:AppCommands.AddNew" 
                 r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar" />
                        <r:RibbonButton Command="me:AppCommands.Cut" 
                 r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar" />
                        <r:RibbonButton Command="me:AppCommands.Copy" 
                 r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar" />
                        <r:RibbonButton Command="me:AppCommands.Paste"  
                 r:RibbonQuickAccessToolBar.Placement="InCustomizeMenuAndToolBar" />
                        <r:RibbonButton Command="me:AppCommands.Help" 
                 r:RibbonQuickAccessToolBar.Placement="InToolBar" />
                    </r:RibbonQuickAccessToolBar>
                </r:Ribbon.QuickAccessToolBar>
                <r:RibbonTab Label="Edit">
                    <r:RibbonTab.Groups>
                        <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}">
                            <r:RibbonGroup.Command>
                                <r:RibbonCommand LabelTitle="Clipboard" SmallImageSource="images/Paste.png" />
                            </r:RibbonGroup.Command>
                            <r:RibbonButton Command="me:AppCommands.Cut"/>
                            <r:RibbonButton Command="me:AppCommands.Copy"/>
                            <r:RibbonButton Command="me:AppCommands.Paste"/>
                        </r:RibbonGroup>

                        <!--<r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}">
                            <r:RibbonGroup.Command>
                                <r:RibbonCommand LabelTitle="File" SmallImageSource="images/AddNew.png" />
                            </r:RibbonGroup.Command>
                            <r:RibbonButton Command="me:AppCommands.AddNew"/>
                            <r:RibbonButton Command="me:AppCommands.Open" />
                            <r:RibbonButton Command="me:AppCommands.Save"/>
                        </r:RibbonGroup>-->

                    </r:RibbonTab.Groups>
                </r:RibbonTab>
                <r:RibbonTab Label="Compile">
                    <r:RibbonTab.Groups>
                        <r:RibbonGroup GroupSizeDefinitions="{StaticResource RibbonLayout}">
                            <r:RibbonGroup.Command>
                                <r:RibbonCommand LabelTitle="CompileProcess" 
                       SmallImageSource="images/CashflowReport.png" />
                            </r:RibbonGroup.Command>
                            <r:RibbonButton Command="me:AppCommands.LexicalAnalysis" />
                            <r:RibbonButton Command="me:AppCommands.SyntaxAnalysis"/>
                            <r:RibbonButton Command="me:AppCommands.SemanticAnalysis"/>
                            <r:RibbonButton Command="me:AppCommands.TargetCodeGeneration"/>
                            </r:RibbonGroup>
                    </r:RibbonTab.Groups>
                </r:RibbonTab>
                <!--<r:Ribbon.ApplicationMenu>
                    <r:RibbonApplicationMenu FontWeight="Bold" FontSize="18.667">
                        <r:RibbonApplicationMenu.Command>
                            <r:RibbonCommand 
                 Executed="OnCloseApplication"
                 LabelTitle="File"
                 LabelDescription="Close the application."
                 SmallImageSource="Images/Coins.png"
                 LargeImageSource="Images/Coins.png"
                 ToolTipTitle="File"
                 ToolTipDescription="Click here to open or save a c- file." />
                        </r:RibbonApplicationMenu.Command>
                    </r:RibbonApplicationMenu>
                </r:Ribbon.ApplicationMenu>-->
                    <r:Ribbon.ApplicationMenu>
                        <r:RibbonApplicationMenu>
                            <r:RibbonApplicationMenu.Command>
                                <r:RibbonCommand SmallImageSource="Images\box.png" LargeImageSource="Images\box.png" />
                            </r:RibbonApplicationMenu.Command>
                            <r:RibbonApplicationMenuItem Command="me:AppCommands.AddNew" />
                            <r:RibbonApplicationMenuItem Command="me:AppCommands.Save" />
                            <r:RibbonApplicationMenuItem Command="me:AppCommands.Open">
                                <!--<TextBlock Text="Item 1 in the list" />
                                <TextBlock Text="Item 2 in the list" />
                                <TextBlock Text="Item 3 in the list" />
                                <TextBlock Text="Item 4 in the list" />-->
                            </r:RibbonApplicationMenuItem>
 
                            <r:RibbonApplicationMenu.RecentItemList>
                                <Rectangle Height="300" />
                            </r:RibbonApplicationMenu.RecentItemList>
                        </r:RibbonApplicationMenu>
                    </r:Ribbon.ApplicationMenu>
                </r:Ribbon>
        </DockPanel>
        <ListView x:Name="dg" 
                  Background="#80909090" AlternationCount="2" ItemContainerStyle="{StaticResource dgRowStyle}" Canvas.Left="324.5" Canvas.Top="147" Width="469" Height="316" >

            <ListView.Resources>
                <Style TargetType="TextBlock">
                    <Setter Property="HorizontalAlignment" Value="Stretch" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                    <Setter Property="MinWidth" Value="50" />
                    <Setter Property="Background" Value="Transparent" />
                </Style>

            </ListView.Resources>

            <ListView.View>
                <GridView ColumnHeaderContainerStyle="{StaticResource dgHeaderStyle}">
                    <GridView.Columns>
                        <GridViewColumn Header="Line" Width="60">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding LineNumber,Mode=OneWay}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Column" Width="70">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding ColumnNumber,Mode=OneWay}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="TokenInfo" Width="150">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding TokenInfo,Mode=OneWay}" FontWeight="Bold" Foreground="DarkBlue" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Lexeme" Width="150">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Lexeme,Mode=OneWay}" FontWeight="Bold" Foreground="DarkBlue" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
            <ListView x:Name="sa" 
                  Background="#80909090" AlternationCount="2" ItemContainerStyle="{StaticResource dgRowStyle}" Canvas.Left="324.5" Canvas.Top="147" Width="469" Height="316" Visibility="Collapsed">

                <ListView.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="HorizontalAlignment" Value="Stretch" />
                        <Setter Property="VerticalAlignment" Value="Center" />
                        <Setter Property="MinWidth" Value="50" />
                        <Setter Property="Background" Value="Transparent" />
                    </Style>

                </ListView.Resources>

                <ListView.View>
                    <GridView ColumnHeaderContainerStyle="{StaticResource dgHeaderStyle}">
                        <GridView.Columns>
                            <GridViewColumn Header="Scope" Width="60">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Scope,Mode=OneWay}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Variable Name" Width="100">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name,Mode=OneWay}" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Type" Width="150">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Type,Mode=OneWay}" FontWeight="Bold" Foreground="DarkBlue" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="Line Numbers" Width="150">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding appear,Mode=OneWay}" FontWeight="Bold" Foreground="DarkBlue" />
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView.Columns>
                    </GridView>
                </ListView.View>
            </ListView>
            <!--<Menu Width="153.5" Height="28" Canvas.Left="8" Canvas.Top="8" IsMainMenu="True">
        	<MenuItem Width="72.5" Height="26" Header="文件">
        		<MenuItem Header="新建"/>
        		<MenuItem Header="打开" Click="MenuItem_Click"/>
        		<MenuItem Header="保存" Click="OnSaveFile"/>
        	</MenuItem>
        	<MenuItem Width="76.5" Height="27" Header="编译">
        		<MenuItem Header="词法分析" Click="LexicalAnalysis"/>
        	</MenuItem>
        </Menu>-->
		<Border CornerRadius="5" Width="316" Height="319" Canvas.Top="145" BorderThickness="1" BorderBrush="#FF737070" Canvas.Left="4.5">
            <RichTextBox x:Name="richTextBox" Width="316" Height="319"  Opacity="0.7" Background="#FFDDF0FC" FontSize="13.333" FontWeight="Bold" BorderThickness="0" AcceptsTab="True">
                    <RichTextBox.ContextMenu>
                        <ContextMenu>
                            <MenuItem Command="Cut">
                                <MenuItem.Icon>
                                    <Image Source="Images/cut.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Command="Copy">
                                <MenuItem.Icon>
                                    <Image Source="Images/copy.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Command="Paste">
                                <MenuItem.Icon>
                                    <Image Source="Images/paste.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                        </ContextMenu>
                    </RichTextBox.ContextMenu>
                    <FlowDocument>
                    <Paragraph x:Name="paragraph" LineHeight="5">
                        <Run x:Name="run" Text="Welcome to C- Compiler!"/>
                    </Paragraph>
                </FlowDocument>
            </RichTextBox>
		</Border>
        <ListView x:Name="error"
        	Background="#80909090" AlternationCount="2" Width="792" Canvas.Top="474.5" Height="120" Canvas.Left="4.5">

        	<ListView.Resources>
        		<Style TargetType="{x:Type TextBlock}">
        			<Setter Property="HorizontalAlignment" Value="Stretch" />
        			<Setter Property="VerticalAlignment" Value="Center" />
        			<Setter Property="MinWidth" Value="50" />
        			
        			<Setter Property="Background" Value="Transparent" />
        		</Style>
        	</ListView.Resources>

        	<ListView.ItemContainerStyle>
        		<StaticResource ResourceKey="dgRowStyle"/>
        	</ListView.ItemContainerStyle>

        	<ListView.View>
        		<GridView  ColumnHeaderContainerStyle="{StaticResource dgHeaderStyle}">
        			<GridViewColumn Header="Line" Width="60">
        				<GridViewColumn.CellTemplate>
        					<DataTemplate>
        						<TextBlock Text="{Binding LineNum,Mode=OneWay}" />
        					</DataTemplate>
        				</GridViewColumn.CellTemplate>
        			</GridViewColumn>
        			<GridViewColumn Header="Column" Width="70">
        				<GridViewColumn.CellTemplate>
        					<DataTemplate>
        						<TextBlock Text="{Binding ColumnNum,Mode=OneWay}" />
        					</DataTemplate>
        				</GridViewColumn.CellTemplate>
        			</GridViewColumn>
        			<GridViewColumn Header="ErrorInfo" Width="300">
        				<GridViewColumn.CellTemplate>
        					<DataTemplate>
                                    <TextBlock Text="{Binding ErrorInfo,Mode=OneWay}" FontWeight="Bold" Foreground="DarkBlue" />
                                </DataTemplate>
        				</GridViewColumn.CellTemplate>
        			</GridViewColumn>
        			<GridViewColumn Header="LexErrorType" Width="150">
        				<GridViewColumn.CellTemplate>
        					<DataTemplate>
        						<TextBlock Text="{Binding LexErrorType,Mode=OneWay}" FontWeight="Bold" Foreground="DarkBlue" />
        					</DataTemplate>
        				</GridViewColumn.CellTemplate>
        			</GridViewColumn>
        		</GridView>
        	</ListView.View>
        </ListView>
    </Canvas>
    </Viewbox>
</r:RibbonWindow>
